home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / DSHJ2 / DRAW.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  45.7 KB  |  1,721 lines

  1. /**************************************************************************/
  2. /*  FILE:  DRAW.C        PROGRAM TITLE: DeskSET II Alpha Version   */
  3. /*  Date Created: 01/11/88                          */ 
  4. /*  Last Modified: 11/16/88                          */
  5. /*                                      */
  6. /*  Description: POLYGON DRAW ROUTINES                      */
  7. /*  Routines:    o   nada()        - Null Function              */
  8. /*              o   poly_draw()        - Draw and Store Polygon      */
  9. /*        o   ellipse_draw()    - Draw and Store Ellipse      */
  10. /*        o   circle_draw()    - Draw and Store Circle          */
  11. /*        o   box_draw()        - Draw and Store Box          */
  12. /*        o   redraw_ellipse()    - Redraw Ellipses and Circles     */
  13. /*        o   redraw_polygon()    - Redraw Polygon          */
  14. /*        o   do_scanner()    - perform rectangle scanning      */
  15. /*        o   do_outline()    - box around selected regions     */
  16. /*        o   do_box()        - draw a filled box...           */
  17. /*        o   write_black()    - set device to write black      */
  18. /*        o   write_white()    - set device to write white      */
  19. /*        o   write_atari()    - set device to write atari logo  */
  20. /*        o   handle_atari()    - write white/atari for images    */
  21. /*        o   handle_write()    - write white/black/pattern      */
  22. /**************************************************************************/
  23.  
  24. /**************************************************************************/
  25. /* INCLUDE FILES                              */
  26. /**************************************************************************/
  27. #include "deskset2.h"
  28. #include <obdefs.h>
  29. #include "gemdefs.h"
  30. #include "define.h"
  31. #include "dbase.h"
  32.  
  33. /**************************************************************************/
  34. /* DEFINES                                  */
  35. /**************************************************************************/
  36. #define max(x,y) (((x) > (y)) ? (x) : (y))
  37. #define min(x,y) (((x) < (y)) ? (x) : (y))
  38.  
  39.  
  40. /**************************************************************************/
  41. /* EXTERNALS                                  */
  42. /**************************************************************************/
  43. extern int phys_handle;                /* Handles, just in case  */
  44. extern int shandle;                /* screen handle          */
  45. extern int phandle;                /* printer handle         */
  46. extern int mhandle;                /* preview buffer handle  */
  47. extern int xor_handle;                /* second screen handle   */
  48. extern int print_flag;                /* printing flag...       */
  49.  
  50. extern int ptsarray[];                /* data struct interface  */
  51. extern int curr_page;                /* current page...        */
  52.  
  53. extern int prev_handle;                /* preview window handle  */
  54.  
  55. extern int pagew,pageh;                /* current width and ht.. */
  56.                         /* in pixels              */
  57. extern mode_flag;                /* solid/text mode        */
  58. extern write_flag;                /* write white/black flag */
  59.  
  60. extern unsigned long page_ptr;            /* preview buffer pointer */
  61. extern unsigned long pagesc;            /* ditto...          */
  62.  
  63. extern unsigned long scanptr;            /* scan buffer pointer    */
  64. extern unsigned long scanesc;            /* ditto...          */
  65.  
  66. extern int scan_xres;                /* scan buffer x res...   */
  67. extern int scan_yres;                /* scan buffer y res...   */
  68.  
  69. extern int mxres,myres;                /* preview buffer x,y res */
  70. extern int rect_in_mu[];            /* rectangle in MU...      */
  71.  
  72. extern int ptsin[];                /* PTSIN[] array          */
  73.  
  74. extern char *tmpptr;                /* CS 2/6/88          */
  75. extern char *endptr;                
  76. extern char *dotext();
  77. extern struct slvll    *getslvptr();        /* Return regions slave ptr */
  78. extern int view_size;                /* current view size      */
  79. extern int axdpi[];                /* xdpi and ydpi arrays   */
  80. extern int aydpi[];
  81. extern int zdevice;
  82.  
  83. extern int pxyarray[];                /* Some global arrays     */
  84. extern int pxy[];                /* ditto          */
  85. extern int status;                /* used by GDv_updwk()    */
  86. extern int dummy;                /* dummy variable filler  */
  87. extern int dumb;
  88.  
  89. extern int cur_scale;                /* current scale...       */
  90. extern int cur_primitive;            /* current graphic        */
  91.                         /* primitive - RCS numbers*/
  92. extern char fbuffer[];                /* file name buffer       */
  93. extern int cur_pic_type;            /* NEO, IMG, GEM      */
  94. extern int graph_flag;                /* graphic region? 1-TRUE */
  95. extern unsigned long gl_grregion_ptr;        /* Ptr to graphic region  */
  96. extern struct txtattr gltxtattr;        /* Global text attr struct*/
  97. extern int glgrattr[];                /* Global graphic attr    */
  98. extern struct textobj gltext;
  99.  
  100. extern FDB laser_MFDB;
  101. extern FDB page_MFDB;
  102.  
  103. extern char cpabt;
  104. extern int opcode;
  105. extern int maxpat;
  106.  
  107. extern REGION *curregion;
  108. extern long getf_scaninfo();
  109. extern long getn_scaninfo();
  110.  
  111. extern int hpage_size;
  112. extern int vpage_size;
  113. extern PNUMBER pnum;
  114.  
  115. extern unsigned char *buf_start;
  116. extern unsigned char *buf_end;
  117. extern unsigned char *free_start;
  118. extern unsigned char *current_char;
  119. extern int tmplate_flag;
  120.  
  121. extern int active_prim;
  122.  
  123. /**************************************************************************/
  124. /* GLOBAL VARIABLES                              */
  125. /**************************************************************************/
  126. int (*funcs)();                    /* current drawing funct. */
  127. int SX,SY;                    /* start scan here...     */
  128. int flag;                    /* variable flag...       */
  129. int SH;                        /* Line spacing for mask  */
  130.  
  131. typedef struct sfdb                /* Scan buffer structure  */
  132.      {
  133.         long BASE;                /* Base address of form   */
  134.         int FORM_WD;                /* form width in bytes.   */
  135.         int FORM_HT;                /* form height (pixels)   */
  136.         int B_XMIN;                /* upper left x          */
  137.         int B_YMIN;                /* upper left y       */
  138.         int B_XMAX;                /* lower left x           */
  139.         int B_YMAX;                /* lower left y           */
  140.      }  SFDB;                    /* name of structure      */
  141.  
  142. SFDB jim_ptr;                    /* pointer to structure   */
  143.  
  144. typedef    struct    mfdb
  145.     {
  146.     long    data;
  147.     int    width;
  148.     int    height;
  149.     int    wwidth;
  150.     int    format;
  151.     int    planes;
  152.     int    res1;
  153.     int    res2;
  154.     int    res3;
  155.     }MFDB;
  156.  
  157. MFDB txtmfdb;                    /* TEXT mfdb CS 2/6/88    */
  158. int mboxx2[254];
  159. int mboxy2[254];
  160. int mboxx1[254];
  161. int mboxy1[254];
  162.  
  163.  
  164. /**************************************************************************/
  165. /* Function:    nada()                              */
  166. /* Description: Null drawing function used as the default.          */
  167. /**************************************************************************/
  168. nada(){}
  169.  
  170.  
  171.  
  172. /**************************************************************************/
  173. /* Function:    poly_draw()                          */
  174. /* Description: Draws polygons                          */
  175. /* IN:  tmp_handle - handle of screen device - xor_handle or shandle      */
  176. /*      num        - number of points.                      */
  177. /* OUT: none                                  */
  178. /* GLOBALS:  xor_handle - screen handle in xor mode              */
  179. /*         shandle    - screen handle in replace mode              */
  180. /*         mhandle    - Preview Buffer handle                  */
  181. /*         pxyarray[] - Vertice coordinates arrive this way...      */
  182. /*           graph_flag - graphic image? - 0 = no, 1 = yes          */
  183. /*         write_flag - write white or write black mode          */
  184. /*              0 = write white, 1 = write black          */
  185. /*         pxy[]      - Vertice coordinates arrive this way          */
  186. /*         ptsarray[] - Data stored in data structure passed in array   */
  187. /**************************************************************************/
  188. poly_draw(tmp_handle,num)
  189. int tmp_handle;
  190. int num;
  191. {
  192.      register int i,cnt;
  193.      int tflag;
  194.      int perimeter;
  195.  
  196.      if(!num)
  197.      return;
  198.      if(tmp_handle == xor_handle)
  199.      v_pline(xor_handle,num,pxyarray);
  200.      else
  201.      {
  202.          if(graph_flag)
  203.      {
  204.         if(cur_primitive == OLINE)
  205.             handle_line(write_flag,mhandle);
  206.         else
  207.                 handle_atari(write_flag,mhandle);
  208.      }
  209.          else
  210.        handle_write(write_flag,mhandle);
  211.  
  212.          tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  213.          cnt = 0;
  214.      for(i=0;i<num;i++)
  215.          {
  216.          scrn2mu(pxy[cnt],pxy[cnt+1],&ptsarray[cnt],&ptsarray[cnt+1],0,tflag);
  217.      mutopage(ptsarray[cnt],ptsarray[cnt+1],
  218.             &pxyarray[cnt],&pxyarray[cnt+1],0);
  219.         cnt+=2;
  220.          }
  221.          mclip();
  222.          if(cur_primitive == OLINE)
  223.      {
  224.        v_pline(mhandle,num,pxyarray);
  225.        put_poly(3,num,write_flag);
  226.          }
  227.      else
  228.          {
  229.            v_fillarea(mhandle,num,pxyarray);
  230.            perimeter = glgrattr[2] & 0x8000;
  231.        if(perimeter && graph_flag)
  232.            {
  233.             handle_line(write_flag,mhandle);
  234.                 v_pline(mhandle,num,pxyarray);
  235.            }
  236.            put_poly(0,num,write_flag);
  237.      }
  238.      }
  239. }
  240.  
  241.  
  242.  
  243.  
  244. /**************************************************************************/
  245. /* Function:    ellipse_draw()                          */
  246. /* Description: 2 stage ellipse draw.                      */
  247. /*        1) arcs are drawn until position is planted.          */
  248. /*        2) ellipse drawn to screen and preview buffer             */
  249. /*        3) ellipse data saved to data structure              */
  250. /*           Data saved in GLOBAL  PTSARRAY[]              */
  251. /* IN:  tmp_handle - screen handle  REPLACE or XOR mode              */
  252. /* GLOBAL: write_flag - writing mode: 0 = write white, 1 = write black    */
  253. /*       ptsarray[] - data for data structures              */
  254. /*         pxyarray[] - used for data manipulation              */
  255. /*       pxy[]      - data arrives in this way              */
  256. /*       graph_flag - graphic image? 0 = no, 1 = yes              */
  257. /*       xor_handle - screen xor mode handle                  */
  258. /*       shandle    - screen replace mode handle              */
  259. /*       mhandle    - preview buffer handle                  */
  260. /**************************************************************************/
  261. ellipse_draw(tmp_handle)
  262. int tmp_handle;
  263. {
  264.     int tflag;
  265.     int perimeter;
  266.  
  267.     perimeter = glgrattr[2] & 0x8000;
  268.     pxyarray[2] = abs(pxy[0] - pxy[2]);
  269.     pxyarray[3] = abs(pxy[1] - pxy[3]);
  270.     
  271.     if(tmp_handle == xor_handle)
  272.             v_ellarc(tmp_handle,pxy[0],pxy[1],
  273.              pxyarray[2],pxyarray[3],0,3600);
  274.     else
  275.     {
  276.          if(graph_flag)
  277.         handle_atari(write_flag,mhandle);
  278.          else
  279.         handle_write(write_flag,mhandle);
  280.  
  281.          tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  282.          scrn2mu(pxy[0],pxy[1],&ptsarray[0],&ptsarray[1],0,tflag);
  283.      mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);        
  284.          scrn2mu(pxyarray[2],pxyarray[3],&ptsarray[2],&ptsarray[3],1,tflag);
  285.      mutopage(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3],1);
  286.  
  287.          mclip();
  288.          v_ellipse(mhandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  289.      if(perimeter && graph_flag)
  290.      {
  291.             handle_line(write_flag,mhandle);
  292.         v_ellarc(mhandle,pxy[0],pxy[1],pxy[2],pxy[3],0,3600);
  293.      }
  294.      put_ellipse(write_flag);
  295.     }
  296. }
  297.  
  298.  
  299.  
  300. /**************************************************************************/
  301. /* Function:    circle_draw()                          */
  302. /* Description: Draws a circle.                          */
  303. /*        1) draws elliptical arcs until planted.              */
  304. /*        2) draws into preview buffer and onto the screen      */
  305. /*        3) Data saved to data structure in GLOBAL PTSARRAY[]      */
  306. /* IN:      tmp_handle   - screen handle   XOR or REPLACE              */
  307. /* GLOBAL: write_flag  - write mode - 0 = write white, 1 = write black..  */
  308. /*       ptsarray[]  - data saved to data structure this way...      */
  309. /*       pxy[]       - data arrives this way...              */
  310. /*       graph_flag  - graphic images? 0 = no, 1 = yes...          */
  311. /*       xor_handle  - screen xor mode handle                  */
  312. /*       shandle     - screen replace mode handle              */
  313. /*       mhandle     - preview buffer handle                  */
  314. /**************************************************************************/
  315. circle_draw(tmp_handle)
  316. {
  317.     int radius;
  318.     int tflag;
  319.     int perimeter;
  320.     int xradius,yradius,temp;
  321.  
  322.     perimeter = glgrattr[2] & 0x8000;    
  323. /*    radius = max(abs(pxy[0] - pxy[2]),abs(pxy[1] - pxy[3]));*/
  324.     xradius = abs(pxy[0] - pxy[2]);
  325.     yradius = abs(pxy[1] - pxy[3]);
  326.     radius = max(xradius,yradius);
  327.   
  328.     if(axdpi[zdevice] == aydpi[zdevice])
  329.               xradius = yradius = radius;
  330.     else
  331.     {
  332.       if(axdpi[zdevice] > aydpi[zdevice])
  333.       {
  334. /*        yradius = scale_v(xradius,aydpi[zdevice],axdpi[zdevice]);  */
  335.           temp = scale_v(yradius,axdpi[zdevice],aydpi[zdevice]);
  336.           if(xradius >= temp)
  337.       {
  338.                yradius = scale_v(xradius,aydpi[zdevice],axdpi[zdevice]);
  339.            radius = xradius;        
  340.           }
  341.           else
  342.           {
  343.            xradius = temp;
  344.            radius = yradius;
  345.           }
  346.       } 
  347.       else
  348.       {
  349.         temp = scale_v(yradius,axdpi[zdevice],aydpi[zdevice]);
  350.         if(xradius >= temp)
  351.         {
  352.              yradius = scale_v(xradius,aydpi[zdevice],axdpi[zdevice]);
  353.          radius = xradius;
  354.         }
  355.         else
  356.         {
  357.       xradius = temp;
  358.           radius = yradius;
  359.         }
  360.       }
  361.     }
  362.  
  363.     if(tmp_handle == xor_handle)
  364.             v_ellarc(tmp_handle,pxy[0],pxy[1],xradius,yradius,0,3600);
  365. /*          v_arc(tmp_handle,pxy[0],pxy[1],radius,0,3600);*/
  366.     else
  367.     {
  368.        if(graph_flag)
  369.         handle_atari(write_flag,mhandle);
  370.        else
  371.         handle_write(write_flag,mhandle);
  372.  
  373.        tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  374.        scrn2mu(pxy[0],pxy[1],&ptsarray[0],&ptsarray[1],0,tflag);
  375.        mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);        
  376.  
  377.        if(axdpi[zdevice] != aydpi[zdevice])
  378.        {
  379.           scrn2mu(xradius,yradius,&ptsarray[2],&ptsarray[3],1,tflag);
  380.           if(xradius >= yradius)
  381.           {
  382.         ptsarray[3] = scale_v(ptsarray[2],1152,1296);
  383.           }
  384.           else
  385.           {
  386.         ptsarray[2] = scale_v(ptsarray[3],1296,1152);       
  387.           }
  388.        }
  389.        else
  390.        {
  391.           scrn2mu(radius,radius,&ptsarray[2],&ptsarray[3],1,tflag);
  392.        }
  393.        mutopage(ptsarray[2],ptsarray[3],&xradius,&yradius,1);
  394.  
  395.        mclip();
  396.        v_ellipse(mhandle,pxy[0],pxy[1],xradius,yradius);
  397.        if(perimeter && graph_flag)
  398.        {
  399.           handle_line(write_flag,mhandle);
  400.           v_ellarc(mhandle,pxy[0],pxy[1],xradius,yradius,0,3600);
  401.        }
  402.        put_ellipse(write_flag);
  403.     }
  404. }
  405.  
  406.  
  407.  
  408. /**************************************************************************/
  409. /* Function:    box_draw()                          */
  410. /* Description: Draws a box.. but saved as a polygon...                */
  411. /*         1) drawn as v_plines until planted.              */
  412. /*        2) box drawn to screen and preview buffer.          */
  413. /*        3) polygon saved to data structure.              */
  414. /*           Data saved in GLOBAL PTSARRAY[]              */
  415. /* IN:    tmp_handle - screen handle in REPLACE or XOR mode          */
  416. /* OUT:   none                                  */
  417. /* GLOBAL:  write_flag - write mode: 0 - write white, 1 - write black.      */
  418. /*        pxyarray[] - Internal data manipulation              */
  419. /*        pxy[]      - Data arrives in this array              */
  420. /*        ptsarray[] - Data passed to data structures through this...   */
  421. /*          cur_primitive - current drawing primitive in RCS units      */
  422. /*        xor_handle - screen xor mode handle                  */
  423. /*        shandle    - screen replace handle                  */
  424. /*        mhandle    - preview buffer handle                  */
  425. /*                                          */
  426. /**************************************************************************/
  427. box_draw(tmp_handle)
  428. int tmp_handle;
  429. {
  430.     register int i;
  431.     int tflag;
  432.     int perimeter;
  433.     int temp;
  434.  
  435.     perimeter = glgrattr[2] & 0x8000;    
  436.  
  437.  
  438.  
  439.     if(tmp_handle == xor_handle)
  440.     {
  441.        pxyarray[0] = pxyarray[6] = pxyarray[8] = pxy[0];
  442.        pxyarray[1] = pxyarray[3] = pxyarray[9] = pxy[1];
  443.        pxyarray[2] = pxyarray[4] = pxy[2];
  444.        pxyarray[5] = pxyarray[7] = pxy[3];
  445.  
  446.        v_pline(tmp_handle,5,pxyarray);
  447.     }
  448.     else
  449.     {
  450.        if(pxy[2] < pxy[0])    /* swap if inverted... */
  451.        {
  452.      temp = pxy[2];
  453.      pxy[2] = pxy[0];
  454.      pxy[0] = temp;
  455.        }
  456.  
  457.        if(pxy[3] < pxy[1])
  458.        {
  459.          temp = pxy[3];
  460.          pxy[3] = pxy[1];
  461.          pxy[1] = temp;
  462.        }
  463.        pxyarray[0] = pxyarray[6] = pxyarray[8] = pxy[0];
  464.        pxyarray[1] = pxyarray[3] = pxyarray[9] = pxy[1];
  465.        pxyarray[2] = pxyarray[4] = pxy[2];
  466.        pxyarray[5] = pxyarray[7] = pxy[3];
  467.  
  468.        if(cur_primitive == OIMAGE)
  469.          write_atari(mhandle);
  470.        else
  471.        {
  472.        if(graph_flag)
  473.          handle_atari(write_flag,mhandle);
  474.            else
  475.          handle_write(write_flag,mhandle);
  476.        }
  477.  
  478.          tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  479.        for(i=0;i<10;i+=2)
  480.        {
  481.          scrn2mu(pxyarray[i],pxyarray[i+1],&ptsarray[i],&ptsarray[i+1],0,tflag);
  482.          mutopage(ptsarray[i],ptsarray[i+1],&pxy[i],&pxy[i+1],0);    
  483.        }
  484.        mclip();
  485.        if(cur_primitive == ORBOX)
  486.        {
  487.         pxyarray[0] = pxy[0];
  488.         pxyarray[1] = pxy[1];
  489.         pxyarray[2] = pxy[4];
  490.         pxyarray[3] = pxy[5];
  491.         v_rfbox(mhandle,pxyarray);
  492.         if(perimeter && graph_flag)
  493.         {
  494.            handle_line(write_flag,mhandle);
  495.            v_rbox(mhandle,pxyarray);
  496.         }
  497.         put_poly(4,5,write_flag);
  498.         return;
  499.        }
  500.        else    
  501.        {
  502.          v_fillarea(mhandle,5,pxy);
  503.      if(perimeter && graph_flag)
  504.          {
  505.             if(cur_primitive == OIMAGE)
  506.         {
  507.            vsl_type(mhandle,1);
  508.            vsl_width(mhandle,1);
  509.         }
  510.         else
  511.            handle_line(write_flag,mhandle);
  512.         if(pxy[0] == pxy[8] &&
  513.            pxy[1] == pxy[9])
  514.            {
  515.               pxy[10]     = pxy[2];
  516.               pxy[11]     = pxy[3];
  517.               v_pline(mhandle,6,pxy);
  518.            }
  519.            else
  520.               v_pline(mhandle,5,pxy);
  521.      }
  522.        }
  523.        if(cur_primitive == OIMAGE)
  524.        {
  525.         remove_path(fbuffer);
  526.             put_image(fbuffer,cur_pic_type);
  527.        }
  528.        else
  529.             put_poly(0,5,write_flag);
  530.     }
  531.  
  532. }
  533.  
  534.  
  535.  
  536. /**************************************************************************/
  537. /* Function:    redraw_ellipse()                      */
  538. /* Description: Redraws ellipse and circle                  */
  539. /*        Depending upon the mode, draws either in black, or draws  */
  540. /*        in black with a filled text outline.              */
  541. /* IN: wflag   - writing mode   -  1 = write black 0 = write white      */
  542. /* OUT: none                                  */
  543. /* GLOBAL:   mode_flag  - solid or text fill                   */
  544. /*         PTSARRAY[] - contains coordinate data.              */
  545. /**************************************************************************/
  546. redraw_ellipse(wflag,g_flag)
  547. int wflag;
  548. int g_flag;
  549. {
  550.    int thandle;
  551.    int perimeter;
  552.  
  553.    perimeter = glgrattr[2] & 0x8000;
  554.    if(!mode_flag)
  555.    {
  556.        if(g_flag)
  557.                handle_atari(wflag,mhandle);
  558.        else
  559.            handle_write(wflag,mhandle);
  560.  
  561.        mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);
  562.        mutopage(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3],1);
  563.        v_ellipse(mhandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  564.        if(perimeter && g_flag)
  565.        {
  566.             handle_line(wflag,mhandle);
  567.         v_ellarc(mhandle,pxy[0],pxy[1],pxy[2],pxy[3],0,3600);
  568.        }
  569.    }
  570.    else
  571.    {
  572.      if(g_flag)
  573.      {
  574.        if(print_flag)
  575.        {
  576.        thandle = phandle;
  577.            mutolas(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1]);
  578.            mutolas(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3]);
  579.        }
  580.        else
  581.        {
  582.        thandle = mhandle;
  583.            mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);
  584.            mutopage(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3],1);
  585.        }
  586.        handle_atari(wflag,thandle);
  587.        v_ellipse(thandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  588.        if(perimeter)
  589.        {
  590.             handle_line(wflag,thandle);
  591.         v_ellarc(thandle,pxy[0],pxy[1],pxy[2],pxy[3],0,3600);
  592.        }
  593.      }
  594.      else
  595.      {
  596.        handle_write(wflag,mhandle);
  597.        mutomem(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1]);
  598.        mutomem(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3]);
  599.        v_ellipse(mhandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  600.      }
  601.    }
  602. }
  603.  
  604.  
  605.  
  606.  
  607. /**************************************************************************/
  608. /* Function:    redraw_polygon()                      */
  609. /* Description:                               */
  610. /**************************************************************************/
  611. redraw_polygon(count,wflag,g_flag)
  612. int count;
  613. int wflag;
  614. int g_flag;
  615. {
  616.    int thandle;
  617.    register int i;
  618.    register int cnt;
  619.    int perimeter;
  620.    int index;
  621.  
  622.    perimeter = glgrattr[2] & 0x8000;
  623.  
  624.    if(!count)
  625.     return;
  626.    if(!mode_flag)
  627.    {
  628.  
  629.        for(i=0;i<(count*2); i += 2)
  630.       mutopage(ptsarray[i],ptsarray[i+1],&pxy[i],&pxy[i+1],0);
  631.  
  632.        if(opcode == 3)
  633.        {
  634.         handle_line(wflag,mhandle);
  635.         v_pline(mhandle,count,pxy);
  636.        }
  637.        else
  638.        {
  639.                if(g_flag)
  640.                      handle_atari(wflag,mhandle);
  641.                 else
  642.                  handle_write(wflag,mhandle);
  643.      
  644.  
  645.         if(opcode == 4)
  646.         {
  647.            pxyarray[0] = pxy[0];
  648.            pxyarray[1] = pxy[1];
  649.            pxyarray[2] = pxy[4];
  650.            pxyarray[3] = pxy[5];
  651.            v_rfbox(mhandle,pxyarray);
  652.            if(perimeter && g_flag)
  653.            {
  654.                 handle_line(write_flag,mhandle);
  655.             v_rbox(mhandle,pxyarray);
  656.            }
  657.         }
  658.         else
  659.             {
  660.                   v_fillarea(mhandle,count,pxy);
  661.                if(perimeter && g_flag)
  662.                    {
  663.                       if(cur_primitive == OIMAGE)
  664.                   {
  665.                      vsl_type(mhandle,1);
  666.                      vsl_width(mhandle,1);
  667.                   }
  668.                   else
  669.                      handle_line(write_flag,mhandle);
  670.               index = count * 2;
  671.               if(pxy[0] == pxy[index - 2] &&
  672.                  pxy[1] == pxy[index - 1])
  673.               {
  674.                  pxy[index]     = pxy[2];
  675.                  pxy[index + 1] = pxy[3];
  676.                  v_pline(mhandle,count+1,pxy);
  677.               }
  678.               else
  679.                  v_pline(mhandle,count,pxy);
  680.                    }
  681.         }
  682.        }
  683.    }
  684.    else
  685.    {
  686.      if(g_flag)
  687.      {
  688.     cnt = 0;
  689.         if(print_flag)
  690.         {
  691.       thandle = phandle;
  692.       for(i=0;i<count;i++)
  693.           {
  694.        mutolas(ptsarray[cnt],ptsarray[cnt+1],&pxy[cnt],&pxy[cnt+1]);
  695.        cnt+= 2;
  696.           }
  697.  
  698.         }
  699.         else
  700.         {
  701.       thandle = mhandle;
  702.       for(i=0;i<count;i++)
  703.           {
  704.        mutopage(ptsarray[cnt],ptsarray[cnt+1],&pxy[cnt],&pxy[cnt+1],0);
  705.        cnt+= 2;
  706.           }
  707.  
  708.         }
  709.  
  710.     
  711.     if(opcode == 3)
  712.     {
  713.          handle_line(wflag,thandle);
  714.          v_pline(thandle,count,pxy);
  715.     }
  716.     else
  717.     {
  718.              handle_atari(wflag,thandle);
  719.          if(opcode == 4)
  720.          {
  721.            pxyarray[0] = pxy[0];
  722.            pxyarray[1] = pxy[1];
  723.            pxyarray[2] = pxy[4];
  724.            pxyarray[3] = pxy[5];
  725.            v_rfbox(thandle,pxyarray);
  726.                if(perimeter)
  727.                    {
  728.               handle_line(write_flag,thandle);
  729.               v_rbox(thandle,pxyarray);
  730.                    }
  731.          }
  732.          else
  733.          {
  734.             v_fillarea(thandle,count,pxy);
  735.             if(perimeter)
  736.                 {
  737.               index = count * 2;
  738.                   handle_line(write_flag,thandle);
  739.               if(pxy[0] == pxy[index - 2] &&
  740.                  pxy[1] == pxy[index - 1])
  741.               {
  742.                  pxy[index]     = pxy[2];
  743.                  pxy[index + 1] = pxy[3];
  744.                  v_pline(thandle,count+1,pxy);
  745.               }
  746.               else
  747.                  v_pline(thandle,count,pxy);
  748.                 }
  749.          }
  750.     }
  751.      }
  752.      else
  753.      {
  754.         handle_write(wflag,mhandle);
  755.         cnt = 0;
  756.     for(i=0;i<count;i++)
  757.         {
  758.        mutomem(ptsarray[cnt],ptsarray[cnt+1],&pxy[cnt],&pxy[cnt+1]);
  759.        cnt+= 2;
  760.         }
  761.     v_fillarea(mhandle,count,pxy);
  762.      }
  763.    }
  764. }
  765.  
  766.  
  767.  
  768. /**************************************************************************/
  769. /* Function:    do_handjreg()                          */
  770. /* Description: Scans the graphic mask in the scan buffer and returns       */
  771. /*        rectangle coordinates.                      */
  772. /* IN:                                        */
  773. /*        txtptr - ptr to text                      */
  774. /*        dflag  - done flag                          */ 
  775. /* OUT: none                                  */
  776. /* GLOBAL:  regx1,regx2,regy1,regy2 - rectangular area of region      */
  777. /*        jim_ptr  - data structure MFDB                   */
  778. /*          scanner() - performs actual scanning of mask.          */
  779. /*        sx1,sx2,sy1,sy2 - rectangle to draw.              */
  780. /**************************************************************************/
  781. extern struct txtattr cp;                  /* using GOG structure */
  782.  
  783. char *do_handjreg(txtptr,dflag,mode,rect_in_mu)
  784. char *txtptr;
  785. int  *dflag;
  786. int  mode;
  787. int  rect_in_mu[];
  788. {
  789.     int  tmp_handle;
  790.     int ptsin1[25];
  791.     int x1,y1,x2,y2;
  792.     int  sx1,sx2,sy1,sy2;
  793.     int  save_sx1;
  794.     FDB  *fdb_ptr;
  795.     int tmppage;
  796.     int muy;
  797.     long line_space;
  798.     int scanoff;
  799.     int dummy;
  800.  
  801.     *dflag = 0;
  802.     line_space = gltxtattr.lnsp;
  803.     tmppage = curr_page;
  804.     if(view_size == PADJCNT)
  805.     {
  806.     curr_page = curregion->p;
  807.     }
  808.     
  809.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  810.     cp.depth = cp.lnsp;
  811.     tmp_handle = shandle;
  812.  
  813.     if(mode == 3)
  814.         resetIFpos();
  815.  
  816.     mutomem(rect_in_mu[0],rect_in_mu[1],&sx1,&sy1);
  817.     mutomem(rect_in_mu[2],rect_in_mu[3],&sx2,&sy2);
  818.  
  819.     muy = rect_in_mu[1];
  820.     muy = max(muy,0);
  821.     if(cp.scoff)
  822.     {
  823.        if(muy + cp.scoff < rect_in_mu[3] )
  824.        {
  825.           muy += cp.scoff;              /* offset into scanner */
  826.       mutomem(muy,muy,&scanoff,&sy1);
  827.        }
  828.     }
  829.  
  830.     jim_ptr.BASE    = scanptr;
  831.     jim_ptr.FORM_WD = ((scan_xres + 15)/16)*2;
  832.     jim_ptr.FORM_HT = scan_yres;
  833.     sx1 = max(sx1,0);
  834.     save_sx1 = sx1;
  835.     sy1 = max(sy1,0);
  836.     sx2 = min(sx2,scan_xres);
  837.     sy2 = min(sy2,scan_yres);
  838.     jim_ptr.B_XMIN  = sx1;
  839.     jim_ptr.B_YMIN  = sy1;
  840.     jim_ptr.B_XMAX  = sx2;
  841.     jim_ptr.B_YMAX  = sy2;
  842.  
  843.     gltext.State = 0;
  844.     gltext.slvlist = 0L;
  845.  
  846.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  847.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  848.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  849.     ptsin1[9] = tmp_handle;
  850.  
  851.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  852.  
  853.     SX = sx1;
  854.     SY = sy1;
  855.     cpabt = 0;
  856.     tmpptr = endptr = txtptr;
  857.     while(scanner(&jim_ptr,SX,SY,SH,&sx1,&sy1,&sx2))
  858.     {
  859.        if(sy1 != SY)
  860.        {
  861.       if(sy1 == SY + SH)            /* Drop down a line */
  862.          muy += line_space - 1;
  863.       else
  864.          memtomu(dummy,sy1,&dummy,&muy);
  865.        }
  866.        if(sx2 == SX - 1 && sy1 == SY)
  867.        {
  868.       muy += line_space - 1;
  869.       SY += SH;        /* Rectangle hasn't moved */
  870.       SX = save_sx1;    /* Set to beginning of next line */
  871.        }
  872.        else
  873.        {
  874.           SX     = sx2 + 1;
  875.           SY     = sy1;
  876.        }
  877.        sy2    = sy1 + SH;
  878.  
  879.        if(muy + line_space - 1 > rect_in_mu[3])
  880.            break;
  881.  
  882.        memtomu(sx1,sy1,&x1,&y1);
  883.        memtomu(sx2,sy2,&x2,&y2);
  884.        
  885.        ptsin1[0] = x1;
  886.        ptsin1[3] = x2;
  887.  
  888.        cp.llen = x2 - x1 + 1;
  889. /*
  890.        cp.depth = (long)(y2 - y1 + 1);
  891.        cp.lnsp = cp.depth; 
  892. */
  893.        ptsin1[1] = ptsin1[4] = 0;
  894.        ptsin1[2] =  y1 = muy;
  895.        ptsin1[5] = y2 = muy + line_space - 1;
  896.        
  897.  
  898.        gltext.begtext   = tmpptr;
  899.        gltext.slvlist = 0L;       
  900.  
  901.        endptr = dotext(&gltext,ptsin1,fdb_ptr,mode,dflag);
  902.        switch(cpabt)
  903.        {
  904.       case 0:
  905.               add_scaninfo(curregion,x1,y1,x2,y2,tmpptr,gltext.slvlist);
  906.         break;
  907.       case 4:
  908.         *dflag = 0;
  909.         endptr = tmpptr;
  910.           freeslvlist(gltext.slvlist);
  911.         break;
  912.       case 8:
  913.               add_scaninfo(curregion,x1,y1,x2,y2,tmpptr,gltext.slvlist);
  914.         *dflag = 0;
  915.         curr_page = tmppage;
  916.         return(endptr);
  917.         break;
  918.       case 1:
  919.       case 2:
  920.       case 3:
  921.       case 5:
  922.       case 6:
  923.       case 7:
  924.           do_txterr(cpabt);
  925.           *dflag = 1;
  926.           break;
  927.        }
  928.  
  929.        if(*dflag)                /* Done */
  930.          break;
  931.        tmpptr = endptr;       
  932.     }
  933.     curr_page = tmppage;    
  934.     return(endptr);
  935. }
  936.  
  937.  
  938.  
  939. /**************************************************************************/
  940. /*    do_regoutput                              */
  941. /**************************************************************************/
  942. do_regoutput(txtptr,dflag)
  943. char *txtptr;
  944. int  *dflag;
  945. {
  946.     int x1,y1,x2,y2;
  947.     long tptr;
  948.     long slvptr;
  949.  
  950.     if(getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr))
  951.     {
  952.       if(slvptr)
  953.       do_output(dflag);
  954.       else
  955.       do_slvout(txtptr,dflag);
  956.     }
  957.     else
  958.       do_slvout(txtptr,dflag);
  959. }    
  960.  
  961.  
  962.  
  963. /**************************************************************************/
  964. /* Function:    do_slvout()                          */
  965. /**************************************************************************/
  966. do_slvout(txtptr,dflag)
  967. char *txtptr;
  968. int  *dflag;
  969. {
  970.     int  tmp_handle;
  971.     int ptsin1[25];
  972.     int x1,y1,x2,y2;
  973.     FDB  *fdb_ptr;
  974.     long *yptr;
  975.     long scanlist;
  976.     long tptr;
  977.     long slvptr;
  978.  
  979.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  980.     tmp_handle = shandle;
  981.  
  982.     resetIFpos();
  983.     gltext.State = 1;
  984.     
  985.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  986.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  987.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  988.     ptsin1[9] = tmp_handle;
  989.     ptsin1[10] = 0;
  990.  
  991.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  992.  
  993.     cpabt = 0;
  994.     tmpptr = txtptr;
  995.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr);
  996.     while(scanlist)
  997.     {
  998.        ptsin1[0] = x1;
  999.        ptsin1[3] = x2;
  1000.  
  1001.        cp.llen = x2 - x1 + 1;
  1002.        cp.depth = (long)(y2 - y1 + 1);
  1003.        cp.lnsp = cp.depth;
  1004.  
  1005.        yptr = (unsigned long *)(ptsin1 + 1);
  1006.        *yptr = (long)y1;
  1007.        yptr = (unsigned long *)(ptsin1 + 4);
  1008.        *yptr = (long)y2; 
  1009.  
  1010.        gltext.begtext   = tmpptr;
  1011.        gltext.slvlist = 0L;   
  1012.        endptr = dotext(&gltext,ptsin1,fdb_ptr,6,dflag);
  1013.  
  1014.        if(endptr == (char *)-1L)
  1015.        {
  1016.        if(cpabt == 4)        /* Line measure too short */
  1017.        {
  1018.         *dflag = 0;
  1019.         endptr = tmpptr;
  1020.        }
  1021.        else
  1022.        {
  1023.           do_txterr(cpabt);
  1024.           break;
  1025.           }
  1026.        }
  1027.        put_scaninfo(scanlist,gltext.slvlist);       
  1028.        if(*dflag)            /* Done or Output only mode */
  1029.          break;
  1030.        tmpptr = endptr;
  1031.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1032.     }
  1033.     
  1034.     if(print_flag) 
  1035.     write_black(mhandle);
  1036. }
  1037.  
  1038.  
  1039. /**************************************************************************/
  1040. /* Function:    do_slvout()                          */
  1041. /**************************************************************************/
  1042. do_slave_only(txtptr,dflag)
  1043. char *txtptr;
  1044. int  *dflag;
  1045. {
  1046.     int  tmp_handle;
  1047.     int ptsin1[25];
  1048.     int x1,y1,x2,y2;
  1049.     FDB  *fdb_ptr;
  1050.     long *yptr;
  1051.     long scanlist;
  1052.     long tptr;
  1053.     long slvptr;
  1054.  
  1055.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  1056.     tmp_handle = shandle;
  1057.  
  1058.     resetIFpos();
  1059.     gltext.State = 1;
  1060.     
  1061.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1062.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1063.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1064.     ptsin1[9] = tmp_handle;
  1065.     ptsin1[10] = 0;
  1066.  
  1067.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1068.  
  1069.     cpabt = 0;
  1070.     tmpptr = txtptr;
  1071.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1072.     while(scanlist)
  1073.     {
  1074.        ptsin1[0] = x1;
  1075.        ptsin1[3] = x2;
  1076.  
  1077.        cp.llen = x2 - x1 + 1;
  1078.        cp.depth = (long)(y2 - y1 + 1);
  1079.        cp.lnsp = cp.depth;
  1080.  
  1081.        yptr = (unsigned long *)(ptsin1 + 1);
  1082.        *yptr = (long)y1;
  1083.        yptr = (unsigned long *)(ptsin1 + 4);
  1084.        *yptr = (long)y2; 
  1085.  
  1086.        gltext.begtext   = tmpptr;
  1087.        gltext.slvlist = 0L;   
  1088.        endptr = dotext(&gltext,ptsin1,fdb_ptr,2,dflag);
  1089.  
  1090.        if(endptr == (char *)-1L)
  1091.        {
  1092.        if(cpabt == 4)        /* Line measure too short */
  1093.        {
  1094.         *dflag = 0;
  1095.         endptr = tmpptr;
  1096.        }
  1097.        else
  1098.        {
  1099.           do_txterr(cpabt);
  1100.           break;
  1101.           }
  1102.        }
  1103.        put_scaninfo(scanlist,gltext.slvlist);       
  1104.        if(*dflag)            /* Done or Output only mode */
  1105.          break;
  1106.        tmpptr = endptr;
  1107.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1108.     }
  1109. }
  1110.  
  1111. /**************************************************************************/
  1112. /* Function:    do_tdoout()                          */
  1113. /**************************************************************************/
  1114. do_tdoout(txtptr,dflag)
  1115. char *txtptr;
  1116. int  *dflag;
  1117. {
  1118.     int  tmp_handle;
  1119.     int ptsin1[25];
  1120.     int x1,y1,x2,y2;
  1121.     FDB  *fdb_ptr;
  1122.     long scanlist;
  1123.     long tptr;
  1124.     long slvptr;
  1125.  
  1126.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  1127.     tmp_handle = shandle;
  1128.  
  1129.     topPge_TYF();
  1130.     gltext.State = 1;
  1131.     
  1132.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1133.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1134.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1135.     ptsin1[9] = tmp_handle;
  1136.     ptsin1[10] = 0;
  1137.  
  1138.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1139.  
  1140.     cpabt = 0;
  1141.     tmpptr = txtptr;
  1142.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1143.     while(scanlist)
  1144.     {
  1145.        ptsin1[0] = x1;
  1146.        ptsin1[3] = x2;
  1147.  
  1148.        cp.llen = x2 - x1 + 1;
  1149.        cp.depth = (long)(y2 - y1 + 1);
  1150.        cp.lnsp = cp.depth;
  1151.  
  1152.        ptsin1[2] = y1;
  1153.        ptsin1[5] = y2;
  1154.        ptsin1[1] = ptsin1[4] = 0;
  1155.  
  1156.        gltext.begtext   = tmpptr;
  1157.        gltext.slvlist = 0L;   
  1158.        endptr = dotext(&gltext,ptsin1,fdb_ptr,2,dflag);
  1159.  
  1160.        if(endptr == (char *)-1L)
  1161.        {
  1162.        if(cpabt == 4)        /* Line measure too short */
  1163.        {
  1164.         *dflag = 0;
  1165.         endptr = tmpptr;
  1166.           freeslvlist(gltext.slvlist);
  1167.        }
  1168.        else
  1169.        {
  1170.           do_txterr(cpabt);
  1171.           break;
  1172.           }
  1173.        }
  1174.        writeslv(gltext.slvlist);       
  1175.        if(*dflag)            /* Done or Output only mode */
  1176.          break;
  1177.        tmpptr = endptr;
  1178.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1179.     }
  1180. }
  1181.  
  1182.  
  1183.  
  1184.  
  1185. /**************************************************************************/
  1186. /* Function:    do_output()                          */
  1187. /**************************************************************************/
  1188. do_output(dflag)
  1189. int  *dflag;
  1190. {
  1191.     int  tmp_handle;
  1192.     int ptsin1[25];
  1193.     int x1,y1,x2,y2;
  1194.     FDB  *fdb_ptr;
  1195.     long scanlist;
  1196.     long tptr;
  1197.  
  1198.     tmp_handle = shandle;
  1199.     
  1200.     resetIFpos();
  1201.     gltext.State = 3;
  1202.  
  1203.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1204.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1205.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1206.     ptsin1[9] = tmp_handle;
  1207.     ptsin1[10] = 0;        /* No clipping */
  1208.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1209.  
  1210.     cpabt = 0;
  1211.  
  1212.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1213.     while(scanlist)
  1214.     {
  1215.        if(gltext.slvlist)
  1216.        {
  1217.           endptr = dotext(&gltext,ptsin1,fdb_ptr,4,dflag);
  1218.  
  1219.           if(endptr == (char *)-1L)
  1220.           {
  1221.           if(cpabt == 4)        /* Line measure too short */
  1222.           {
  1223.          *dflag = 0;
  1224.           }
  1225.           else
  1226.           {
  1227.              do_txterr(cpabt);
  1228.              break;
  1229.              }
  1230.       }
  1231.        }
  1232.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1233.     }
  1234.     
  1235.     if(print_flag) 
  1236.     write_black(mhandle);
  1237. }
  1238.  
  1239.  
  1240.  
  1241.  
  1242. /**************************************************************************/
  1243. /* Function:    do_clipregout()                          */
  1244. /**************************************************************************/
  1245. do_clipregout(clx1,cly1,clx2,cly2)
  1246. int clx1,cly1,clx2,cly2;
  1247. {
  1248.     int  tmp_handle;
  1249.     int ptsin1[25];
  1250.     int x1,y1,x2,y2;
  1251.     FDB  *fdb_ptr;
  1252.     long scanlist;
  1253.     long tptr;
  1254.     int dflag;
  1255.     int rx1,ry1,rx2,ry2;
  1256.     int pos_not_set;
  1257.     int rx[4];
  1258.     int sx[4];
  1259.     int oldy, offset_y;
  1260.     oldy = 0;
  1261.     tmp_handle = shandle;
  1262.     
  1263.     resetIFpos();
  1264.     gltext.State = 3;
  1265.  
  1266.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1267.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1268.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1269.     ptsin1[9] = tmp_handle;
  1270.     ptsin1[10] = 1;        /*  clipping */
  1271.     ptsin1[11] = sx[0] = clx1;
  1272.     ptsin1[12] = sx[1] = cly1;
  1273.     ptsin1[13] = sx[2] = clx2 + 1;    /* 1 pixel off on clipping */
  1274.     ptsin1[14] = sx[3] = cly2 + 1;
  1275.  
  1276.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1277.  
  1278.     cpabt = 0;
  1279.  
  1280.  
  1281.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1282.     mutopage(x1,y1,&rx[0],&rx[1],0);
  1283.     mutopage(x2,y2,&rx[2],&rx[3],0);
  1284.     if(rect_intersect(rx,sx))
  1285.     {
  1286.     resetIFpos();
  1287.     pos_not_set = 0;
  1288.     }
  1289.     else
  1290.     pos_not_set = 1;
  1291.     while(scanlist)
  1292.     {
  1293.        if(gltext.slvlist)
  1294.        { 
  1295.           if(oldy != y1)        /* Need to add line space to all */
  1296.       {                /* scanrects that don't have     */
  1297.              oldy = offset_y = y1;    /* positioning info in them      */
  1298.                      /* i.e. a scan directly to the   */
  1299.       }                /* right and parallel with another */
  1300.       else                /* scan                   */
  1301.       {
  1302.                 offset_y = y1 + curregion->text.lnsp - 1;
  1303.         pos_not_set = 1;
  1304.       }
  1305.           mutopage(x1,y1,&rx[0],&rx[1],0);
  1306.           mutopage(x2,y2,&rx[2],&rx[3],0);
  1307.           if(rect_intersect(rx,sx))        /* if the scan overlaps the clip*/
  1308.           {
  1309.          if(pos_not_set)
  1310.          {
  1311.         setYpos(offset_y);
  1312.         pos_not_set = 0;
  1313.          }
  1314.              endptr = dotext(&gltext,ptsin1,fdb_ptr,4,&dflag);
  1315.              if(endptr == (char *)-1L)
  1316.              {
  1317.                 if(cpabt == 4)        /* Line measure too short */
  1318.             {
  1319.           dflag = 0;
  1320.             }
  1321.             else
  1322.             {
  1323.                do_txterr(cpabt);
  1324.                break;
  1325.                }
  1326.              }
  1327.       }
  1328.        }
  1329.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1330.     }
  1331.     
  1332.     if(print_flag) 
  1333.     write_black(mhandle);
  1334. }
  1335.  
  1336.  
  1337.  
  1338. /**************************************************************************/
  1339. /* Function:    do_outer()                          */
  1340. /* Description:                                  */
  1341. /**************************************************************************/
  1342. do_outer(handle,pxy)
  1343. int handle;
  1344. register int pxy[];
  1345. {
  1346.    int txy[10];
  1347.  
  1348.    txy[0] = pxy[0] - 5;txy[1] = pxy[1] - 5;
  1349.    txy[2] = pxy[2] + 5;txy[3] = pxy[3] + 5;
  1350.    do_box(handle,txy[0],txy[1],txy[2],txy[3]);
  1351. }
  1352.  
  1353.  
  1354.  
  1355. do_outline(handle,pxy)
  1356. int handle;
  1357. register int pxy[];
  1358. {
  1359.    int midx,midy;
  1360.    int txy[10];
  1361.    register int i;
  1362.      
  1363.       txy[0] = pxy[0] - 5;txy[1] = pxy[1] - 5;
  1364.       txy[2] = pxy[2] + 5;txy[3] = pxy[3] + 5;
  1365.       do_box(handle,txy[0],txy[1],txy[2],txy[3]);
  1366.  
  1367.       if(active_prim)
  1368.       {
  1369.     midx = (txy[0] + txy[2])/2;
  1370.     midy = (txy[1] + txy[3])/2;
  1371.  
  1372.  
  1373.     mboxx1[1] = mboxx1[5] = midx;
  1374.     mboxy1[0] = mboxy1[1] = mboxy1[2] = txy[1];
  1375.  
  1376.     mboxx1[2] = mboxx1[3] = mboxx1[4] = txy[2];
  1377.     mboxy1[3] = mboxy1[7] = midy;
  1378.  
  1379.     mboxy1[4] = mboxy1[5] = mboxy1[6] = txy[3];
  1380.  
  1381.     mboxx1[0] = mboxx1[6] = mboxx1[7] = txy[0];
  1382.  
  1383.  
  1384.     for(i=0;i<=8;i++)
  1385.         do_diamond(handle,mboxx1[i],mboxy1[i]);
  1386.       }
  1387.  
  1388.        mboxx1[0] = mboxx1[6] = mboxx1[7] = txy[0] - 3;
  1389.        mboxx2[0] = mboxx2[6] = mboxx2[7] = txy[0] + 3;
  1390.        mboxx1[2] = mboxx1[3] = mboxx1[4] = txy[2] - 3;
  1391.        mboxx2[2] = mboxx2[3] = mboxx2[4] = txy[2] + 3;
  1392.        mboxy1[0] = mboxy1[1] = mboxy1[2] = txy[1] - 3;
  1393.        mboxy2[0] = mboxy2[1] = mboxy2[2] = txy[1] + 3;
  1394.        mboxy1[4] = mboxy1[5] = mboxy1[6] = txy[3] - 3;
  1395.        mboxy2[4] = mboxy2[5] = mboxy2[6] = txy[3] + 3;
  1396.        midx = (txy[0] + txy[2])/2;
  1397.        midy = (txy[1] + txy[3])/2;
  1398.        mboxx1[1] = mboxx1[5] = midx - 3;
  1399.        mboxx2[1] = mboxx2[5] = midx + 3;
  1400.  
  1401.        mboxy1[3] = mboxy1[7] = midy - 3;
  1402.        mboxy2[3] = mboxy2[7] = midy + 3;
  1403.       
  1404.       if(!active_prim)
  1405.       {
  1406.         for(i=0;i<8;i++)
  1407.            do_box(handle,mboxx1[i],mboxy1[i],mboxx2[i],mboxy2[i]);
  1408.       }
  1409.       
  1410. }
  1411.  
  1412.  
  1413.  
  1414. do_diamond(handle,x1,y1)
  1415. int handle;
  1416. int x1,y1;
  1417. {
  1418.     pxyarray[0] = pxyarray[8] = x1-5;
  1419.     pxyarray[1] = pxyarray[9] = pxyarray[5] = y1;
  1420.  
  1421.     pxyarray[2] = pxyarray[6] = x1;
  1422.     pxyarray[3] = y1 - 5;
  1423.  
  1424.     pxyarray[4] = x1 + 5;
  1425.     pxyarray[7] = y1 + 5;
  1426.     v_pline(handle,5,pxyarray);
  1427. }
  1428.  
  1429.  
  1430.  
  1431.  
  1432. /**************************************************************************/
  1433. /* Function:    do_box()                          */
  1434. /* Description: Called by do_scan to draw the rectangle bar into the      */
  1435. /*        workstation buffer designated by handle...          */
  1436. /**************************************************************************/
  1437. do_box(handle,x1,y1,x2,y2)
  1438. int handle;
  1439. int x1,y1,x2,y2;
  1440. {
  1441.     pxyarray[0] = pxyarray[6] = pxyarray[8] = x1;
  1442.     pxyarray[1] = pxyarray[3] = pxyarray[9] = y1;
  1443.     pxyarray[2] = pxyarray[4] = x2;
  1444.     pxyarray[5] = pxyarray[7] = y2;
  1445.     v_pline(handle,5,pxyarray);
  1446. }
  1447.  
  1448.  
  1449.  
  1450. /**************************************************************************/
  1451. /* Function:    write_black()                          */
  1452. /* Description: switches fill style for writing to solid black.          */
  1453. /**************************************************************************/
  1454. write_black(handle)
  1455. int handle;
  1456. {
  1457.    vsf_interior(handle,1);
  1458.    vsf_perimeter(handle,FALSE);
  1459. }
  1460.  
  1461.  
  1462.  
  1463. /**************************************************************************/
  1464. /* Function:    write_white()                          */
  1465. /* Description: Changes device fill style to write in white.          */
  1466. /**************************************************************************/
  1467. write_white(handle)
  1468. int handle;
  1469. {
  1470.    vsf_interior(handle,0);
  1471.    vsf_perimeter(handle,FALSE);
  1472. }
  1473.  
  1474.  
  1475.  
  1476. /**************************************************************************/
  1477. /* Function:    write_atari()                          */
  1478. /* Description:                                  */
  1479. /**************************************************************************/
  1480. write_atari(handle)
  1481. int handle;
  1482. {
  1483. int curindex;
  1484. int curstyle;
  1485.  
  1486.      if((cur_primitive == OIMAGE) || (opcode == 2))
  1487.      {
  1488.         vsf_interior(handle,4);
  1489.      }
  1490.      else
  1491.      {
  1492.     curstyle = glgrattr[2] & 0x7fff;
  1493.     curindex = glgrattr[3];
  1494.     if(curstyle == 2)
  1495.     {
  1496.            if(curindex >= maxpat)
  1497.           curstyle = 0;                /* Hollow    */
  1498.     }
  1499.         vsf_interior(handle,curstyle);
  1500.         vsf_style(handle,curindex);
  1501.      }
  1502.      vsf_perimeter(handle,0);        /* handle perimeter ourselves   */
  1503. }
  1504.  
  1505.  
  1506.  
  1507. /**************************************************************************/
  1508. /* Function:    handle_atari()                          */
  1509. /* Description:                                  */
  1510. /**************************************************************************/
  1511. handle_atari(wflag,handle)
  1512. int wflag;
  1513. int handle;
  1514. {
  1515.      if(wflag)
  1516.            write_atari(handle);
  1517.      else 
  1518.        write_white(handle);
  1519. }
  1520.  
  1521.  
  1522.  
  1523. /**************************************************************************/
  1524. /* Function:    handle_write()                          */
  1525. /* Description:                                  */
  1526. /**************************************************************************/
  1527. handle_write(wflag,handle)
  1528. int wflag;
  1529. int handle;
  1530. {
  1531.        if(wflag)
  1532.        write_black(handle);
  1533.        else
  1534.        write_white(handle);
  1535. }
  1536.  
  1537.  
  1538.  
  1539. handle_line(wflag,handle)
  1540. int wflag;
  1541. int handle;
  1542. {
  1543.         int tmpwidth;
  1544.     int dummy;
  1545.         int mu_width;
  1546.  
  1547.     if(wflag)
  1548.         vsl_color(handle,TRUE);
  1549.     else
  1550.         vsl_color(handle,FALSE);
  1551.     if(glgrattr[1])            /* If line width in points... */
  1552.         vsl_type(handle,1);        /* Set style to solid        */
  1553.     else                /* Else single line so use pattern */
  1554.        vsl_type(handle,glgrattr[0]);
  1555.         if(!glgrattr[1])            /* line width of 1 */
  1556.        tmpwidth = 1;
  1557.         else
  1558.     {
  1559.        mu_width = pttomu(glgrattr[1]);
  1560.        if(handle == phandle)
  1561.           mutolas(dummy,mu_width,&dummy,&tmpwidth);
  1562.        else
  1563.           mutopage(dummy,mu_width,&dummy,&tmpwidth,1);
  1564.         }
  1565.     vsl_width(handle,tmpwidth);
  1566. }
  1567.  
  1568.  
  1569.  
  1570. /***********************************************************************/
  1571. /* Function: do_numbers()                           */
  1572. /* Description: Print actual page numbers...                   */
  1573. /***********************************************************************/
  1574. do_numbers(rgrect,tdo_flag)
  1575. int rgrect[];
  1576. int tdo_flag;
  1577. {
  1578.    long *yptr;
  1579.    FDB *fdbptr;
  1580.    int dflag;
  1581.    register int i,j;
  1582.    int size;
  1583.    int ptype;
  1584.    int y1,y2;
  1585.    int vbase;
  1586.    int ptsin1[25];
  1587.    char str[4];
  1588.    char text[PTEXTMAX];
  1589.    int just;
  1590.    int tgrect[4];
  1591.    int tpxy[4];
  1592.  
  1593.  
  1594.    if(pnum.display && pnum.text[0] && !tmplate_flag)
  1595.    {            /* display on and text exists and not template mode */
  1596.  
  1597.      ptype = ((curr_page%2)?(1):(0));
  1598.  
  1599.      if((pnum.usage == 0) && ptype)
  1600.             return;
  1601.      if((pnum.usage == 1) && !ptype)
  1602.             return;
  1603.  
  1604.      if((curr_page < pnum.fpage) || (curr_page > pnum.tpage))
  1605.                     return;
  1606.  
  1607.      just = ((ptype)?(pnum.rjust):(pnum.ljust));
  1608.      switch(just)
  1609.      {
  1610.       case 0: pnum.tattrib.jstmd = 1;    /* quad left  */
  1611.           break;
  1612.       case 1: pnum.tattrib.jstmd = 3;    /* quad center*/
  1613.           break;
  1614.       case 2: pnum.tattrib.jstmd = 2;    /* quad right */
  1615.           break;
  1616.      };
  1617.      f_move(&pnum.tattrib,&cp,sizeof(cp));
  1618.  
  1619.      if(tdo_flag)
  1620.     topPge_TYF();
  1621.      else
  1622.         resetIFpos();
  1623.  
  1624.      for(i=0;i<=4;i++)
  1625.        str[i] = 0x0;
  1626.      for(i=0;i<=PTEXTMAX;i++)
  1627.             text[i] = 0x0;
  1628.  
  1629.      itoa(curr_page,str);
  1630.      i=0;
  1631.      j=0;
  1632.      while((pnum.text[i]) && (i<=PTEXTMAX))
  1633.      {
  1634.     if(pnum.text[i] != '#')
  1635.         text[j++] = pnum.text[i];
  1636.         else
  1637.         {
  1638.        if(pnum.text[i+1] == '#')
  1639.        {
  1640.         text[j++] = pnum.text[i];
  1641.         i++;
  1642.        }
  1643.        j += strlen(str);
  1644.        if(j<=PTEXTMAX)
  1645.            strcat(text,str);
  1646.        else
  1647.          i=PTEXTMAX;
  1648.         }
  1649.     i++;
  1650.      }
  1651.  
  1652.      buf_start =  &text[0];
  1653.      buf_end   =  &text[PTEXTMAX];
  1654.  
  1655.      size = strlen(&text[0]);
  1656.      free_start = size + buf_start;
  1657.      current_char = buf_end;
  1658.  
  1659.  
  1660.      vbase = ((pnum.vpos)?(vpage_size):(0));    /* top or bottom? */
  1661.      y1 = ((vbase)?(vbase - pnum.distance):(pnum.distance));
  1662.      y2 = y1 + pttomu((pnum.pptsize / 8) + 5);
  1663.  
  1664.      if((print_flag) || (view_size != PADJCNT))
  1665.      {
  1666.         ptsin1[0] = 0;
  1667.         ptsin1[3] = hpage_size;
  1668.      }
  1669.      else
  1670.      {
  1671.     ptsin1[0] = ((curr_page % 2)?(hpage_size):(0));
  1672.     ptsin1[3] = ((curr_page % 2)?(2*hpage_size):(hpage_size));
  1673.      }
  1674.  
  1675.      if(rgrect)
  1676.      {
  1677.         mutopage(ptsin1[0],y1,&tpxy[0],&tpxy[1],0);
  1678.         mutopage(ptsin1[3],y2,&tpxy[2],&tpxy[3],0);
  1679.  
  1680.     tgrect[0] = tpxy[0];
  1681.         tgrect[1] = tpxy[1];
  1682.         tgrect[2] = tpxy[2] - tpxy[0] + 1;
  1683.         tgrect[3] = tpxy[3] - tpxy[1] + 1;
  1684.      }
  1685.  
  1686.      if(!rgrect || rc_intersect(rgrect,tgrect))
  1687.      {
  1688.        yptr = (unsigned long *)(ptsin1 + 1);
  1689.        *yptr = (long)y1;
  1690.        yptr = (unsigned long *)(ptsin1 + 4);
  1691.        *yptr = (long)y2;
  1692.  
  1693.  
  1694.        ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1695.        ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1696.        ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1697.        ptsin1[9] = shandle;
  1698.        ptsin1[10] = 0;                    /* no clip flag */
  1699.  
  1700.        fdbptr = ((print_flag) ? (&laser_MFDB) : (&page_MFDB));     
  1701.  
  1702.  
  1703.        gltext.State = 1;
  1704.        gltext.slvlist = 0L;
  1705.        gltext.begtext = buf_start;
  1706.  
  1707.        cp.llen = ptsin1[3] - ptsin1[0] + 1;
  1708.        cp.depth = (long)(y2 - y1 + 1);
  1709.        cp.lnsp = cp.depth;
  1710.        if(tdo_flag)
  1711.        {
  1712.      endptr = dotext(&gltext,ptsin1,fdbptr,2,&dflag);
  1713.      writeslv(gltext.slvlist);
  1714.        }
  1715.        else
  1716.          endptr = dotext(&gltext,ptsin1,fdbptr,6,&dflag);
  1717.      }
  1718.    }    /* pnum.display == FALSE */
  1719.  
  1720. }
  1721.